// 用于处理线程问题
self.onmessage = function (e) {
    const {
        CHUNK_SIZE,
        file,
        chunkNum
    } = e.data
    console.log('数据:', e.data)
    for (let chunkIndex = 0; chunkIndex < chunkNum; chunkIndex++) {
        const start = chunkIndex * CHUNK_SIZE
        const end = Math.min(start + CHUNK_SIZE, file.size)
        const chunkContent = file.slice(start, end)
        let fileReader = new FileReader()
        fileReader.readAsArrayBuffer(chunkContent)
        fileReader.onprogress = function () {
            // self.postMessage({
            //     type: 'progress',
            //     content: `第${chunkIndex + 1}块上传进度：${((chunkIndex + 1) / chunkNum * 100).toFixed(2)}%`
            // })
        }
        fileReader.onload = function (event) {
            self.postMessage({
                type: 'fileInfo',
                content: {
                    start,
                    end,
                    blob: event.target.result,
                    index: chunkIndex,
                    // hash: 
                }
            })
            fileReader.abort()
        }
        fileReader.onerror = function (event) {
            console.log('error:', event)
            fileReader.abort()
        }
    }

}